<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <!-- import CSS -->
  <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
</head>
<style>
  #app{
    width: 1024px;
    height: 683px;
    margin: 0 auto;
    background-image: url("./imgs/login_background.jpg") ;
  }
  #login{

    width: 280px;
    height: 60px;
    margin: 200px 330px;
  }

</style>

<body>
<div id="app">
  <el-container>
    <el-main class="center">
      <el-row >
        <el-col span="24">
          <!--          登录表单开始-->
          <el-form id="login" label-width="80px">
            <h1>仓储管理系统</h1>
            <el-form-item label="用户名"><el-input placeholder="请输入用户名" v-model="user.userName"></el-input></el-form-item>
            <el-form-item label="密码"><el-input placeholder="密码" v-model="user.password"></el-input></el-form-item>
            <el-form-item ><el-button type="primary" @click="login()">登录</el-button></el-form-item>
          </el-form>
          <!--          注册表单结束-->
        </el-col>
      </el-row>
    </el-main>
  </el-container>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<!--引入Axios-->
<script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
<script>
  let v = new Vue({
    el: '#app',
    data: function() {
      return {
        user: {userName:"",password:""}
      }
    },
    methods:{
      login(){
        axios.post("/v1/users/login",v.user).then(function (response) {
          if(response.data.code==1){
            v.$message.success("登录成功");
            location.href="index.html"
          }else {
            v.$message.error("账户名或密码错误");
          }
        })
      }
    }
  })
</script>
</html>